package com.jinsi.controller.yrf;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jinsi.constant.YrfConstant;
import com.jinsi.pojo.SyFeedbackList;
import com.jinsi.service.yrf.FeedbackListService;
import com.jinsi.util.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author: 86185
 * @description: 反馈列表
 * @date 2022/9/5
 */
@RestController
@RequestMapping("/feedbackManagement")
@Slf4j
public class FeedbackListController {

    @Autowired
    private FeedbackListService feedbackManagementService;


    /**
     * 获取所有数据(模糊查询)
     * @param page 分页
     * @param limit 分页
     * @param sorw 受理状态
     * @param syFeedbackList 模糊查
     *
     */

    @RequestMapping("/getAll")
    public R getAll(Integer page, Integer limit, Integer sorw, SyFeedbackList syFeedbackList){
        PageHelper.startPage(page,limit);
        List<SyFeedbackList> all = feedbackManagementService.getAll(sorw,syFeedbackList);
        PageInfo<SyFeedbackList> pageInfo = new PageInfo<>(all);

        return R.custom(YrfConstant.LAYUI_CODE,
                YrfConstant.LAYUI_MSG,
                pageInfo.getList(),
                pageInfo.getTotal());

    }
    /**
     *获取待受理人数
     * @param span1 根据span1获取
     */
    @RequestMapping("/span1")
    public R span1(Integer span1){

        Map<String,Object> map = new HashMap<>();
        int num = feedbackManagementService.span1(span1);
        map.put("num",num);
        map.put("msg","成功");
        log.info("获取待受理人数为: ---> "+num);

        return R.ok(map);

    }
    /**
     * 获取已受理人数
     * @param span1 根据span1获取
     *
     */
    @RequestMapping("/span2")
    public R span2(Integer span1){

        Map<String,Object> map = new HashMap<>();
        int num = feedbackManagementService.span2(span1);
        map.put("num",num);
        map.put("msg","成功");

        log.info("获取已受理人数为: ---> "+num);
        return R.ok(map);

    }

    /**
     * 修改受理状态
     * @param bid 根据bid修改状态
     *
     */
    @RequestMapping("/updStaBybid")
    public R updListFild(Integer bid){
        feedbackManagementService.updListFild(bid);
        return R.ok("成功");

    }





}
